```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分布式缓存原理与技术 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #111;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
        }
        .code-block {
            background-color: #f8f9fa;
            border-left: 4px solid #667eea;
        }
        .highlight-text {
            position: relative;
            z-index: 1;
        }
        .highlight-text::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(102, 126, 234, 0.2);
            z-index: -1;
            transition: all 0.3s ease;
        }
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            margin-bottom: 1rem;
            color: white;
            font-size: 1.5rem;
        }
        .nav-link {
            position: relative;
        }
        .nav-link::after {
            content: '';
            position: absolute;
            bottom: -2px;
            left: 0;
            width: 0;
            height: 2px;
            background-color: #667eea;
            transition: width 0.3s ease;
        }
        .nav-link:hover::after {
            width: 100%;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Navigation -->
    <nav class="bg-white shadow-sm py-4 sticky top-0 z-50">
        <div class="container mx-auto px-6 flex justify-between items-center">
            <a href="#" class="text-2xl font-bold text-gray-800">技术小馆</a>
            <div class="hidden md:flex space-x-8">
                <a href="#concept" class="nav-link text-gray-700 hover:text-gray-900">核心概念</a>
                <a href="#architecture" class="nav-link text-gray-700 hover:text-gray-900">架构设计</a>
                <a href="#workflow" class="nav-link text-gray-700 hover:text-gray-900">工作原理</a>
                <a href="#technologies" class="nav-link text-gray-700 hover:text-gray-900">技术选型</a>
                <a href="#problems" class="nav-link text-gray-700 hover:text-gray-900">常见问题</a>
            </div>
            <button class="md:hidden text-gray-600">
                <i class="fas fa-bars text-xl"></i>
            </button>
        </div>
    </nav>

    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6 flex flex-col md:flex-row items-center">
            <div class="md:w-1/2 mb-10 md:mb-0">
                <h1 class="text-4xl md:text-5xl font-bold mb-4">分布式缓存原理与技术</h1>
                <p class="text-xl mb-8 opacity-90">构建高性能、高可用分布式系统的关键技术</p>
                <div class="flex flex-wrap gap-4">
                    <a href="#concept" class="bg-white text-indigo-700 px-6 py-3 rounded-lg font-medium hover:bg-gray-100 transition">开始探索</a>
                    <a href="#technologies" class="border-2 border-white text-white px-6 py-3 rounded-lg font-medium hover:bg-white hover:text-indigo-700 transition">技术比较</a>
                </div>
            </div>
            <div class="md:w-1/2">
                <div class="bg-white bg-opacity-10 p-6 rounded-2xl backdrop-blur-sm">
                    <div class="mermaid">
                        graph TD
                            A[客户端] -->|请求数据| B[分布式缓存]
                            B -->|缓存命中| C[返回缓存数据]
                            B -->|缓存未命中| D[查询数据库]
                            D --> E[写入缓存]
                            E --> C
                            F[缓存节点1] --数据同步--> G[缓存节点2]
                            G --数据同步--> H[缓存节点3]
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Intro Section -->
    <section class="py-16 bg-white">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <p class="text-lg text-gray-600 mb-8">
                    随着微服务架构和大规模系统的普及，分布式缓存已经成为了提高应用性能、降低数据库压力和保障系统可扩展性的重要工具。无论是高并发的电商平台，还是分布式的大数据处理系统，缓存都扮演着至关重要的角色。
                </p>
                <div class="flex justify-center">
                    <div class="w-24 h-1 bg-indigo-500 rounded-full"></div>
                </div>
            </div>
        </div>
    </section>

    <!-- Concept Section -->
    <section id="concept" class="py-16 bg-gray-50">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <h2 class="text-3xl font-bold mb-4">分布式缓存的基本概念</h2>
                <p class="text-gray-600 max-w-2xl mx-auto">
                    分布式缓存是指通过网络连接多个缓存节点，在多个节点之间共享缓存数据，从而在大规模系统中提升数据访问速度
                </p>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-16">
                <div>
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1734256152123-ab815bef-3d3e-45f3-a9a1-d2f8575f7112.png" 
                         alt="分布式缓存示意图" class="rounded-lg shadow-md w-full h-auto">
                </div>
                <div>
                    <h3 class="text-2xl font-bold mb-4">缓存的定义与作用</h3>
                    <p class="text-gray-700 mb-6">
                        缓存是一种存储机制，用于临时存放频繁访问的数据副本，以加速数据的读取操作。在传统的单机应用中，缓存通常部署在本地内存中，而在分布式系统中，缓存被扩展至多个物理节点之间，通过分布式的方式共同提供数据服务。
                    </p>
                    <div class="grid grid-cols-2 gap-4">
                        <div class="bg-white p-4 rounded-lg shadow-sm border-l-4 border-indigo-500">
                            <h4 class="font-bold mb-2">提高访问速度</h4>
                            <p class="text-sm text-gray-600">减少重复查询数据库的操作</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm border-l-4 border-purple-500">
                            <h4 class="font-bold mb-2">降低数据库压力</h4>
                            <p class="text-sm text-gray-600">缓解数据库的高并发压力</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm border-l-4 border-blue-500">
                            <h4 class="font-bold mb-2">优化系统性能</h4>
                            <p class="text-sm text-gray-600">显著提升热点数据访问性能</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm border-l-4 border-green-500">
                            <h4 class="font-bold mb-2">实现负载均衡</h4>
                            <p class="text-sm text-gray-600">分散请求到多个缓存节点</p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-16">
                <div class="md:flex">
                    <div class="md:w-1/2 p-8">
                        <h3 class="text-2xl font-bold mb-4">分布式缓存的工作原理</h3>
                        <ul class="space-y-4">
                            <li class="flex items-start">
                                <div class="bg-indigo-100 text-indigo-600 p-2 rounded-full mr-4">
                                    <i class="fas fa-database"></i>
                                </div>
                                <div>
                                    <h4 class="font-bold">数据存入缓存</h4>
                                    <p class="text-gray-600 text-sm">首次访问时从数据源读取并存入缓存</p>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <div class="bg-purple-100 text-purple-600 p-2 rounded-full mr-4">
                                    <i class="fas fa-bolt"></i>
                                </div>
                                <div>
                                    <h4 class="font-bold">缓存命中</h4>
                                    <p class="text-gray-600 text-sm">后续请求直接从缓存获取数据</p>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <div class="bg-blue-100 text-blue-600 p-2 rounded-full mr-4">
                                    <i class="fas fa-clock"></i>
                                </div>
                                <div>
                                    <h4 class="font-bold">缓存失效</h4>
                                    <p class="text-gray-600 text-sm">通过过期时间或主动清理管理生命周期</p>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <div class="bg-green-100 text-green-600 p-2 rounded-full mr-4">
                                    <i class="fas fa-sync-alt"></i>
                                </div>
                                <div>
                                    <h4 class="font-bold">数据一致性</h4>
                                    <p class="text-gray-600 text-sm">强一致性或最终一致性策略</p>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="md:w-1/2 bg-gray-50 p-8 flex items-center">
                        <div class="mermaid w-full">
                            sequenceDiagram
                                participant Client
                                participant Cache
                                participant Database
                                Client->>Cache: 请求数据
                                alt 缓存命中
                                    Cache-->>Client: 返回缓存数据
                                else 缓存未命中
                                    Cache->>Database: 查询数据
                                    Database-->>Cache: 返回数据
                                    Cache-->>Client: 返回数据
                                end
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-3 gap-8">
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="feature-icon bg-indigo-500">
                        <i class="fas fa-expand-arrows-alt"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">扩展性</h3>
                    <p class="text-gray-600">横向扩展，通过增加缓存节点处理更大的数据量和更高的并发请求</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="feature-icon bg-purple-500">
                        <i class="fas fa-shield-alt"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">高可用性</h3>
                    <p class="text-gray-600">数据冗余、复制等技术保证节点故障时不影响整体可用性</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="feature-icon bg-blue-500">
                        <i class="fas fa-balance-scale"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">负载均衡</h3>
                    <p class="text-gray-600">一致性哈希算法均衡分配缓存数据，避免节点瓶颈</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Architecture Section -->
    <section id="architecture" class="py-16 bg-white">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <h2 class="text-3xl font-bold mb-4">分布式缓存的架构设计</h2>
                <p class="text-gray-600 max-w-2xl mx-auto">
                    分布式缓存架构是构建高效、高可用系统的重要组成部分，需要满足高性能、高可用性、可扩展性和数据一致性等要求
                </p>
            </div>

            <div class="mb-16">
                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1734256210480-e9d5c884-e7cc-43ac-be12-6dfe6f7fe5b5.png" 
                     alt="分布式缓存架构设计" class="rounded-lg shadow-md w-full h-auto">
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-16">
                <div>
                    <h3 class="text-2xl font-bold mb-4">缓存数据的分布策略</h3>
                    <div class="space-y-6">
                        <div>
                            <h4 class="font-bold text-lg mb-2 flex items-center">
                                <span class="bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-2">1</span>
                                水平分片 (Sharding)
                            </h4>
                            <p class="text-gray-600 pl-8">通过一致性哈希算法将数据分布到多个节点上，每个节点负责一部分数据，降低单个节点压力</p>
                        </div>
                        <div>
                            <h4 class="font-bold text-lg mb-2 flex items-center">
                                <span class="bg-purple-100 text-purple-600 rounded-full w-6 h-6 flex items-center justify-center mr-2">2</span>
                                复制 (Replication)
                            </h4>
                            <p class="text-gray-600 pl-8">在多个节点上保留同样的数据副本，提高可用性和容错能力，但增加同步复杂度</p>
                        </div>
                        <div>
                            <h4 class="font-bold text-lg mb-2 flex items-center">
                                <span class="bg-blue-100 text-blue-600 rounded-full w-6 h-6 flex items-center justify-center mr-2">3</span>
                                数据一致性
                            </h4>
                            <p class="text-gray-600 pl-8">强一致性确保数据始终一致，最终一致性接受短时间延迟但最终达成一致</p>
                        </div>
                    </div>
                </div>
                <div>
                    <h3 class="text-2xl font-bold mb-4">缓存更新策略</h3>
                    <div class="overflow-hidden rounded-lg shadow-md">
                        <div class="border-b border-gray-200">
                            <div class="flex items-center justify-between p-4 bg-gray-50">
                                <span class="font-medium">策略</span>
                                <span class="font-medium">优点</span>
                                <span class="font-medium">缺点</span>
                            </div>
                        </div>
                        <div class="divide-y divide-gray-200">
                            <div class="flex items-center justify-between p-4 hover:bg-gray-50">
                                <span class="font-medium">写入时更新 (Write-through)</span>
                                <span class="text-green-600 text-sm">确保一致性</span>
                                <span class="text-red-600 text-sm">写入延迟高</span>
                            </div>
                            <div class="flex items-center justify-between p-4 hover:bg-gray-50">
                                <span class="font-medium">延迟写入 (Write-behind)</span>
                                <span class="text-green-600 text-sm">提高写入性能</span>
                                <span class="text-red-600 text-sm">可能数据丢失</span>
                            </div>
                            <div class="flex items-center justify-between p-4 hover:bg-gray-50">
                                <span class="font-medium">缓存失效 (Cache eviction)</span>
                                <span class="text-green-600 text-sm">管理内存使用</span>
                                <span class="text-red-600 text-sm">可能导致雪崩</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="bg-indigo-50 rounded-xl p-8 mb-16">
                <h3 class="text-2xl font-bold mb-6 text-indigo-800">高可用性设计</h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white p-6 rounded-lg">
                        <div class="text-indigo-600 mb-3">
                            <i class="fas fa-copy fa-2x"></i>
                        </div>
                        <h4 class="font-bold mb-2">数据复制</h4>
                        <p class="text-gray-600 text-sm">通过将数据在多个节点之间进行复制，确保即使某个缓存节点出现故障，数据仍然可用</p>
                    </div>
                    <div class="bg-white p-6 rounded-lg">
                        <div class="text-indigo-600 mb-3">
                            <i class="fas fa-exchange-alt fa-2x"></i>
                        </div>
                        <h4 class="font-bold mb-2">故障转移</h4>
                        <p class="text-gray-600 text-sm">在节点发生故障时，系统应自动切换到健康的节点，保证系统的持续服务</p>
                    </div>
                    <div class="bg-white p-6 rounded-lg">
                        <div class="text-indigo-600 mb-3">
                            <i class="fas fa-heartbeat fa-2x"></i>
                        </div>
                        <h4 class="font-bold mb-2">健康检查</h4>
                        <p class="text-gray-600 text-sm">定期检查各个缓存节点的健康状态，及时发现并处理节点故障</p>
                    </div>
                </div>
            </div>

            <h3 class="text-2xl font-bold mb-6">常见的分布式缓存技术比较</h3>
            <div class="overflow-x-auto">
                <table class="min-w-full bg-white rounded-lg overflow-hidden">
                    <thead class="bg-gray-100">
                        <tr>
                            <th class="py-3 px-4 text-left font-semibold text-gray-700">技术</th>
                            <th class="py-3 px-4 text-left font-semibold text-gray-700">特点</th>
                            <th class="py-3 px-4 text-left font-semibold text-gray-700">适用场景</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-200">
                        <tr class="hover:bg-gray-50">
                            <td class="py-4 px-4 font-medium">Redis</td>
                            <td class="py-4 px-4 text-gray-600">高性能，丰富数据结构，支持持久化</td>
                            <td class="py-4 px-4 text-gray-600">缓存、会话存储、排行榜等</td>
                        </tr>
                        <tr class="hover:bg-gray-50">
                            <td class="py-4 px-4 font-medium">Memcached</td>
                            <td class="py-4 px-4 text-gray-600">简单高效，键值存储，无持久化</td>
                            <td class="py-4 px-4 text-gray-600">简单缓存场景</td>
                        </tr>
                        <tr class="hover:bg-gray-50">
                            <td class="py-4 px-4 font-medium">Hazelcast</td>
                            <td class="py-4 px-4 text-gray-600">分布式数据结构，计算功能</td>
                            <td class="py-4 px-4 text-gray-600">分布式计算、缓存共享</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </section>

    <!-- Workflow Section -->
    <section id="workflow" class="py-16 bg-gray-50">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <h2 class="text-3xl font-bold mb-4">分布式缓存的工作原理</h2>
                <p class="text-gray-600 max-w-2xl mx-auto">
                    分布式缓存系统通过将常用的数据存储在内存中，减少对数据库的访问，从而提升系统的响应速度与整体性能
                </p>
            </div>

            <div class="grid md:grid-cols-3 gap-8 mb-16">
                <div class="bg-white p-8 rounded-xl shadow-md">
                    <div class="text-indigo-600 text-4xl mb-4">
                        <i class="fas fa-arrow-circle-down"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">数据写入缓存</h3>
                    <p class="text-gray-600">
                        当客户端发起写请求时，系统首先检查数据是否已存在。如果不存在，则从数据库查询并存入缓存，减少后续数据库访问。
                    </p>
                </div>
                <div class="bg-white p-8 rounded-xl shadow-md">
                    <div class="text-purple-600 text-4xl mb-4">
                        <i class="fas fa-arrow-circle-up"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">数据读取缓存</h3>
                    <p class="text-gray-600">
                        当客户端发起读取请求时，优先从缓存获取数据(命中)。未命中时从数据库读取并存入缓存，便于后续使用。
                    </p>
                </div>
                <div class="bg-white p-8 rounded-xl shadow-md">
                    <div class="text-blue-600 text-4xl mb-4">
                        <i class="fas fa-clock"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">缓存数据过期</h3>
                    <p class="text-gray-600">
                        设置缓存数据的过期时间(TTL)，超时后被淘汰。采用LRU、LFU等策略移除不再需要的数据，保证缓存效率。
                    </p>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-16">
                <div class="md:flex">
                    <div class="md:w-1/2 p-8">
                        <h3 class="text-2xl font-bold mb-4">数据分布与分片</h3>
                        <div class="space-y-6">
                            <div>
                                <h4 class="font-bold flex items-center mb-2">
                                    <span class="bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-2">
                                        <i class="fas fa-project-diagram text-sm"></i>
                                    </span>
                                    一致性哈希
                                </h4>
                                <p class="text-gray-600 pl-8">
                                    将缓存键映射到哈希环上，节点映射到环上，确保数据分布均匀，节点增减时影响最小。
                                </p>
                            </div>
                            <div>
                                <h4 class="font-bold flex items-center mb-2">
                                    <span class="bg-purple-100 text-purple-600 rounded-full w-6 h-6 flex items-center justify-center mr-2">
                                        <i class="fas fa-expand text-sm"></i>
                                    </span>
                                    范围哈希
                                </h4>
                                <p class="text-gray-600 pl-8">
                                    按数据范围划分分片，每个分片存储一定范围数据。适用于数据分布均匀场景。
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class="md:w-1/2 bg-gray-50 p-8 flex items-center">
                        <div class="mermaid w-full">
                            graph LR
                                A[客户端] --> B[一致性哈希环]
                                B --> C[节点1]
                                B --> D[节点2]
                                B --> E[节点3]
                                style B fill:#f5f5f5,stroke:#333,stroke-width:2px
                                style C fill:#e3f2fd,stroke:#2196f3
                                style D fill:#e3f2fd,stroke:#2196f3
                                style E fill:#e3f2fd,stroke:#2196f3
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <h3 class="text-2xl font-bold mb-4">高可用性设计</h3>
                    <div class="bg-white p-6 rounded-lg shadow-sm mb-6">
                        <div class="flex items-start">
                            <div class="bg-green-100 text-green-600 p-3 rounded-full mr-4">
                                <i class="fas fa-clone"></i>
                            </div>
                            <div>
                                <h4 class="font-bold mb-2">数据复制</h4>
                                <p class="text-gray-600 text-sm">
                                    通过主从复制机制，将数据同时保存到多个节点上。主节点负责读写，从节点负责读取，提高可用性与并发性能。
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <div class="flex items-start">
                            <div class="bg-red-100 text-red-600 p-3 rounded-full mr-4">
                                <i class="fas fa-heartbeat"></i>
                            </div>
                            <div>
                                <h4 class="font-bold mb-2">故障转移与备份</h4>
                                <p class="text-gray-600 text-sm">
                                    节点故障时自动将请求转发到健康节点，通过心跳机制监测节点状态，故障时触发备份或故障转移。
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
                <div>
                    <h3 class="text-2xl font-bold mb-4">一致性与同步</h3>
                    <div class="space-y-4">
                        <div class="bg-white p-5 rounded-lg shadow-sm border-l-4 border-indigo-500">
                            <h4 class="font-bold mb-2">强一致性</h4>
                            <p class="text-gray-600 text-sm">
                                每次缓存更新时同步更新数据库，确保缓存与数据库数据始终一致。通过写时更新(Write-through)或延迟写入(Write-behind)实现。
                            </p>
                        </div>
                        <div class="bg-white p-5 rounded-lg shadow-sm border-l-4 border-purple-500">
                            <h4 class="font-bold mb-2">最终一致性</h4>
                            <p class="text-gray-600 text-sm">
                                允许缓存和数据库内容可能不一致，但最终会达成一致。通过定时刷新、批量更新等方式保证最终一致性。
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Technologies Section -->
    <section id="technologies" class="py-16 bg-white">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <h2 class="text-3xl font-bold mb-4">常见的分布式缓存技术</h2>
                <p class="text-gray-600 max-w-2xl mx-auto">
                    分布式缓存技术通过将缓存数据分布在多个服务器节点上以提高系统性能和可扩展性
                </p>
            </div>

            <div class="grid md:grid-cols-3 gap-8 mb-16">
                <div class="bg-red-50 rounded-xl overflow-hidden shadow-md card-hover">
                    <div class="h-48 bg-red-600 flex items-center justify-center">
                        <i class="fas fa-memory text-white text-6xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-bold mb-2">Redis</h3>
                        <p class="text-gray-600 mb-4">
                            当前最流行的分布式缓存技术之一，具备高性能、丰富的数据结构以及多种持久化方式。
                        </p>
                        <div class="flex flex-wrap gap-2">
                            <span class="bg-red-100 text-red-800 text-xs px-3 py-1 rounded-full">高性能</span>
                            <span class="bg-red-100 text-red-800 text-xs px-3 py-1 rounded-full">多种数据结构</span>
                            <span class="bg-red-100 text-red-800 text-xs px-3 py-1 rounded-full">持久化</span>
                        </div>
                    </div>
                </div>
                <div class="bg-blue-50 rounded-xl overflow-hidden shadow-md card-hover">
                    <div class="h-48 bg-blue-600 flex items-center justify-center">
                        <i class="fas fa-bolt text-white text-6xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-bold mb-2">Memcached</h3>
                        <p class="text-gray-600 mb-4">
                            高效的分布式缓存系统，主要用于存储简单的键值对数据，设计简单，广泛用于减轻数据库压力。
                        </p>
                        <div class="flex flex-wrap gap-2">
                            <span class="bg-blue-100 text-blue-800 text-xs px-3 py-1 rounded-full">高性能</span>
                            <span class="bg-blue-100 text-blue-800 text-xs px-3 py-1 rounded-full">简单键值</span>
                            <span class="bg-blue-100 text-blue-800 text-xs px-3 py-1 rounded-full">无持久化</span>
                        </div>
                    </div>
                </div>
                <div class="bg-green-50 rounded-xl overflow-hidden shadow-md card-hover">
                    <div class="h-48 bg-green-600 flex items-center justify-center">
                        <i class="fas fa-network-wired text-white text-6xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-bold mb-2">Hazelcast</h3>
                        <p class="text-gray-600 mb-4">
                            开源的内存计算平台，支持分布式数据结构、分布式缓存、计算任务等，提供对分布式内存的透明访问。
                        </p>
                        <div class="flex flex-wrap gap-2">
                            <span class="bg-green-100 text-green-800 text-xs px-3 py-1 rounded-full">分布式结构</span>
                            <span class="bg-green-100 text-green-800 text-xs px-3 py-1 rounded-full">计算任务</span>
                            <span class="bg-green-100 text-green-800 text-xs px-3 py-1 rounded-full">高可用</span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="bg-gray-50 rounded-xl p-8 mb-16">
                <h3 class="text-2xl font-bold mb-6">其他分布式缓存技术</h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h4 class="font-bold mb-2 flex items-center">
                            <span class="bg-indigo-100 text-indigo-600 rounded-lg w-8 h-8 flex items-center justify-center mr-2">
                                <i class="fas fa-fire"></i>
                            </span>
                            Apache Ignite
                        </h4>
                        <p class="text-gray-600 text-sm mt-2">
                            内存计算平台，支持数据存储、分布式计算和流处理，可用作缓存、数据库及内存计算集群。
                        </p>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h4 class="font-bold mb-2 flex items-center">
                            <span class="bg-purple-100 text-purple-600 rounded-lg w-8 h-8 flex items-center justify-center mr-2">
                                <i class="fas fa-key"></i>
                            </span>
                            Etcd
                        </h4>
                        <p class="text-gray-600 text-sm mt-2">
                            分布式键值存储系统，常用于服务发现、配置管理，保证强一致性，适用于高一致性场景。
                        </p>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h4 class="font-bold mb-2 flex items-center">
                            <span class="bg-blue-100 text-blue-600 rounded-lg w-8 h-8 flex items-center justify-center mr-2">
                                <i class="fas fa-cogs"></i>
                            </span>
                            Consul
                        </h4>
                        <p class="text-gray-600 text-sm mt-2">
                            分布式服务发现和配置管理工具，支持服务发现、健康检查和分布式键值存储功能。
                        </p>
                    </div>
                </div>
            </div>

            <h3 class="text-2xl font-bold mb-6">技术选型指南</h3>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="grid md:grid-cols-4 bg-gray-100 border-b border-gray-200">
                    <div class="p-4 font-semibold">特性</div>
                    <div class="p-4 font-semibold">Redis</div>
                    <div class="p-4 font-semibold">Memcached</div>
                    <div class="p-4 font-semibold">Hazelcast</div>
                </div>
                <div class="grid md:grid-cols-4 border-b border-gray-200 hover:bg-gray-50">
                    <div class="p-4 font-medium">数据结构</div>
                    <div class="p-4 text-gray-600">丰富(字符串、哈希、列表等)</div>
                    <div class="p-4 text-gray-600">简单键值对</div>
                    <div class="p-4 text-gray-600">分布式数据结构</div>
                </div>
                <div class="grid md:grid-cols-4 border-b border-gray-200 hover:bg-gray-50">
                    <div class="p-4 font-medium">持久化</div>
                    <div class="p-4 text-gray-600">支持(RDB/AOF)</div>
                    <div class="p-4 text-gray-600">不支持</div>
                    <div class="p-4 text-gray-600">支持</div>
                </div>
                <div class="grid md:grid-cols-4 border-b border-gray-200 hover:bg-gray-50">
                    <div class="p-4 font-medium">集群模式</div>
                    <div class="p-4 text-gray-600">支持</div>
                    <div class="p-4 text-gray-600">支持</div>
                    <div class="p-4 text-gray-600">支持</div>
                </div>
                <div class="grid md:grid-cols-4 hover:bg-gray-50">
                    <div class="p-4 font-medium">适用场景</div>
                    <div class="p-4 text-gray-600">复杂缓存需求，持久化</div>
                    <div class="p-4 text-gray-600">简单键值缓存</div>
                    <div class="p-4 text-gray-600">分布式计算，内存网格</div>
                </div>
            </div>
        </div>
    </section>

    <!-- Problems Section -->
    <section id="problems" class="py-16 bg-gray-50">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <h2 class="text-3xl font-bold mb-4">分布式缓存的常见问题</h2>
                <p class="text-gray-600 max-w-2xl mx-auto">
                    分布式缓存的使用面临一系列挑战，解决这些问题对于保持系统的稳定性和高效性至关重要
                </p>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-16">
                <div>
                    <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                        <div class="bg-red-600 p-4 text-white font-bold flex items-center">
                            <i class="fas fa-exclamation-triangle mr-2"></i>
                            缓存雪崩
                        </div>
                        <div class="p-6">
                            <p class="text-gray-600 mb-4">
                                当大量缓存数据在同一时间过期时，导致大量请求直接访问数据库，瞬间增加数据库压力，可能导致数据库崩溃。
                            </p>
                            <div class="bg-red-50 p-4 rounded-lg">
                                <h4 class="font-bold text-red-800 mb-2">解决方案：</h4>
                                <ul class="list-disc list-inside text-red-700 space-y-1">
                                    <li>缓存过期时间随机化</li>
                                    <li>热点数据的缓存预热</li>
                                    <li>降级策略避免频繁访问数据库</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="bg-white rounded-xl shadow-md overflow-hidden">
                        <div class="bg-purple-600 p-4 text-white font-bold flex items-center">
                            <i class="fas fa-shield-alt mr-2"></i>
                            缓存击穿
                        </div>
                        <div class="p-6">
                            <p class="text-gray-600 mb-4">
                                某个热点数据的缓存突然失效，并且此时恰好有大量请求同时访问这个数据，导致所有请求都会直接访问数据库。
                            </p>
                            <div class="bg-purple-50 p-4 rounded-lg">
                                <h4 class="font-bold text-purple-800 mb-2">解决方案：</h4>
                                <ul class="list-disc list-inside text-purple-700 space-y-1">
                                    <li>互斥锁(Mutex)机制</li>
                                    <li>队列机制异步更新缓存</li>
                                    <li>永不过期策略+后台更新</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div>
                    <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                        <div class="bg-blue-600 p-4 text-white font-bold flex items-center">
                            <i class="fas fa-search-minus mr-2"></i>
                            缓存穿透
                        </div>
                        <div class="p-6">
                            <p class="text-gray-600 mb-4">
                                请求的键在缓存中不存在，同时也不存在于数据库中。这种请求将直接穿透缓存，访问数据库，导致数据库压力增大。
                            </p>
                            <div class="bg-blue-50 p-4 rounded-lg">
                                <h4 class="font-bold text-blue-800 mb-2">解决方案：</h4>
                                <ul class="list-disc list-inside text-blue-700 space-y-1">
                                    <li>布隆过滤器拦截无效请求</li>
                                    <li>缓存空对象(null或空集合)</li>
                                    <li>参数校验过滤非法请求</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="bg-white rounded-xl shadow-md overflow-hidden">
                        <div class="bg-green-600 p-4 text-white font-bold flex items-center">
                            <i class="fas fa-sync-alt mr-2"></i>
                            数据一致性
                        </div>
                        <div class="p-6">
                            <p class="text-gray-600 mb-4">
                                缓存中的数据与主数据源(如数据库)中的数据不一致，特别是在高并发场景下缓存失效或更新时容易出现。
                            </p>
                            <div class="bg-green-50 p-4 rounded-lg">
                                <h4 class="font-bold text-green-800 mb-2">解决方案：</h4>
                                <ul class="list-disc list-inside text-green-700 space-y-1">
                                    <li>写时更新缓存(Write-Through)</li>
                                    <li>延迟写入(Write-Behind)</li>
                                    <li>过期时间与缓存刷新策略</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <h3 class="text-2xl font-bold mb-6">其他常见问题与解决方案</h3>
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="grid md:grid-cols-5 border-b border-gray-200 bg-gray-100">
                    <div class="p-4 font-semibold">问题</div>
                    <div class="p-4 font-semibold">现象</div>
                    <div class="p-4 font-semibold">原因</div>
                    <div class="p-4 font-semibold">影响</div>
                    <div class="p-4 font-semibold">解决方案</div>
                </div>
                <div class="grid md:grid-cols-5 border-b border-gray-200 hover:bg-gray-50">
                    <div class="p-4 font-medium">缓存并发</div>
                    <div class="p-4 text-gray-600">多线程同时更新缓存数据不一致</div>
                    <div class="p-4 text-gray-600">缺乏并发控制</div>
                    <div class="p-4 text-gray-600">数据错误，业务异常</div>
                    <div class="p-4 text-gray-600">乐观锁/悲观锁，CAS操作</div>
                </div>
                <div class="grid md:grid-cols-5 border-b border-gray-200 hover:bg-gray-50">
                    <div class="p-4 font-medium">缓存容量</div>
                    <div class="p-4 text-gray-600">缓存达到上限，性能下降</div>
                    <div class="p-4 text-gray-600">数据增长超过缓存容量</div>
                    <div class="p-4 text-gray-600">缓存命中率下降</div>
                    <div class="p-4 text-gray-600">LRU/LFU策略，多级缓存</div>
                </div>
                <div class="grid md:grid-cols-5 border-b border-gray-200 hover:bg-gray-50">
                    <div class="p-4 font-medium">数据安全</div>
                    <div class="p-4 text-gray-600">敏感数据泄露</div>
                    <div class="p-4 text-gray-600">缺乏隔离或加密</div>
                    <div class="p-4 text-gray-600">安全风险，合规问题</div>
                    <div class="p-4 text-gray-600">租户隔离设计，加密存储</div>
                </div>
                <div class="grid md:grid-cols-5 hover:bg-gray-50">
                    <div class="p-4 font-medium">跨节点事务</div>
                    <div class="p-4 text-gray-600">多节点数据不一致</div>
                    <div class="p-4 text-gray-600">缺乏分布式事务支持</div>
                    <div class="p-4 text-gray-600">业务逻辑错误</div>
                    <div class="p-4 text-gray-600">分布式事务协议，最终一致性</div>
                </div>
            </div>

            <div class="bg-indigo-50 rounded-xl p-8">
                <h3 class="text-2xl font-bold mb-6 text-indigo-800">缓存问题综合解决方案</h3>
                <div class="mermaid">
                    flowchart TD
                        A[缓存问题] --> B[缓存雪崩]
                        A --> C[缓存击穿]
                        A --> D[缓存穿透]
                        A --> E[数据不一致]
                        
                        B --> F1[过期时间随机化]
                        B --> F2[缓存预热]
                        B --> F3[降级策略]
                        
                        C --> G1[互斥锁]
                        C --> G2[队列异步更新]
                        C --> G3[永不过期+后台更新]
                        
                        D --> H1[布隆过滤器]
                        D --> H2[缓存空对象]
                        D --> H3[参数校验]
                        
                        E --> I1[写时更新]
                        E --> I2[延迟写入]
                        E --> I3[过期策略]
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12">
        <div class="container mx-auto px-6">
            <div class="flex flex-col items-center">
                <div class="text-2xl font-bold mb-4">技术小馆</div>
                <div class="mb-6">
                    <a href="http://www.yuque.com/jtostring" class="text-gray-400 hover:text-white transition">http://www.yuque.com/jtostring</a>
                </div>
                <div class="flex space-x-6">
                    <a href="#" class="text-gray-400 hover:text-white transition">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition">
                        <i class="fab fa-linkedin text-xl"></i>
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```